﻿using Inovout.Kuajing.Models;
using Inovout.Repositories;
using NHibernate.Criterion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Inovout.Kuajing.Repositories
{
    public class ShipmentOrderRepository : DataObjectRepository<ShipmentOrder>
    {
        public IList<ShipmentOrder> FindByShipper(int shipperId)
        {
            var list = base.OpenSession().CreateCriteria<ShipmentOrder>()
                // .Add(Restrictions.Eq("Status", ShipmentOrderStatus.Determined))
                 .Add(Restrictions.Eq("Status", ShipmentOrderStatus.Determined))
                 .CreateCriteria("Shipper", "shipper")
                 .Add(Restrictions.Eq("shipper.Id", shipperId))
                .List<ShipmentOrder>();
            return list;
        }


        public IList<ShipmentOrder> FindUnShipmentOrderByShipper(int shipperId)
        {
            var list = base.OpenSession().CreateCriteria<ShipmentOrder>()
                .Add(Restrictions.Ge("Status", ShipmentOrderStatus.Ordering))
                .Add(Restrictions.Lt("Status", ShipmentOrderStatus.Determined))
                 //.Add(Restrictions.Lt("Status", ShipmentOrderStatus.Determined))
                .CreateCriteria("Shipper", "shipper")
                .Add(Restrictions.Eq("shipper.Id", shipperId))
                .List<ShipmentOrder>();
            return list;
        }

    }
}
